#include <dcmtk/dcmdata/dctk.h>
#include <iostream>
#include <pcre2.h>

void test_dcmtk() {
  std::cout << "DCMTK Version: " << OFFIS_DCMTK_VERSION << "\n";

  DcmFileFormat file;
  std::cout << "DICOM file structure created successfully!\n";
}

void test_pcre2() {
  const char *pattern = R"((\d{4})-(\d{2})-(\d{2}))";
  const char *subject = "Date: 2023-10-05";

  pcre2_code *re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0,
                                 nullptr, nullptr, nullptr);

  if (re) {
    pcre2_match_data *match = pcre2_match_data_create_from_pattern(re, nullptr);
    int rc = pcre2_match(re, (PCRE2_SPTR)subject, PCRE2_ZERO_TERMINATED, 0, 0,
                         match, nullptr);

    if (rc > 0) {
      std::cout << "PCRE2 match succeeded!\n";
      PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match);
      for (int i = 0; i < rc; ++i) {
        std::cout << "Match " << i << ": "
                  << std::string(subject + ovector[2 * i],
                                 subject + ovector[2 * i + 1])
                  << "\n";
      }
    }
    pcre2_match_data_free(match);
    pcre2_code_free(re);
  }
}

int main() {
  std::cout << "\n=== Testing DCMTK ===\n";
  test_dcmtk();

  std::cout << "\n=== Testing PCRE2 ===\n";
  test_pcre2();

  return 0;
}